package com.goods.business.converter;

import com.goods.common.model.business.Consumer;
import com.goods.common.vo.business.ConsumerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class ConsumerConverter {
  public static List<ConsumerVO> converterToVOList(List<Consumer> consumers){
    List<ConsumerVO> consumerVOS = new ArrayList<>();
    if (!CollectionUtils.isEmpty(consumers)){
      for (Consumer consumer : consumers) {
        ConsumerVO consumerVO = converterToConsumerVO(consumer);
        consumerVOS.add(consumerVO);
      }
    }
    return consumerVOS;
  }

  public static ConsumerVO converterToConsumerVO(Consumer consumer) {
    ConsumerVO consumerVO = new ConsumerVO();
    BeanUtils.copyProperties(consumer,consumerVO);
    return consumerVO;
  }
}
